<% /* $Id: contestlanguages.jsp 132 2011-08-26 10:23:42Z altdotua@gmail.com $ */ %>

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>

<%@ include file="../header.jsp" %>

<%= (new ContestLanguagesFormatter(true, requestUrlEncoded)).format(ContestLanguagesModel.getEntries(filter)) %>

<%
	ContestLanguageEntry entry = ContestLanguagesModel.getEntry(Long.parseLong(request.getParameter("id")));
%>

<h2><%= entry == null ? "Add contest language" : "Edit contest language\"" + entry + "\"" %></h2>

<form action="<%= Linker.link("contestlanguages") %>" method="post">
	<input type="hidden" name="action" value="edit">
  	<p><input type="hidden" name="id" value="<%= null == entry ? "" : entry.getId() %>"></p>
  	<p>Contest<select name="contestId">
<%
	List<ContestEntry> contests = ContestsModel.getAllEntries();
	String contestId = null != entry ? entry.getContestId().toString() : "";
	for (ContestEntry contest2 : contests)
	{
%>
		<option value="<%=contest2.getId()%>" <%= contest2.getId().toString().equals(contestId) ? " selected=\"selected\"" : "" %>><%=contest2%> 
<%
 	}
%>
	</select></p>  
  <p>Language<select name="languageId">
<%
	List<LanguageEntry> languages = LanguagesModel.getAllEntries();
	String languageId = null != entry ? entry.getLanguageId().toString() : "";
	for (LanguageEntry language : languages)
	{
%>
		<option value="<%= language.getId() %>" <%= language.getId().toString().equals(languageId) ? " selected=\"selected\"" : "" %>><%= language %> 
<%
 	}
%>
	</select></p>  
  <p><input type="checkbox" name="active" <%= null == entry || entry.getActive() ? "checked='checked'" : "" %>>Active?</p>
  <p><input type="submit" value="Submit"></p>
</form>


<%@ include file="../footer.jsp" %>
